using Services;
using UnityEngine;

public class PlayerPanel : MonoBehaviour
{
    private MyCanvasGrounp myCanvasGrounp;

    private void Awake()
    {
        ServiceLocator.Get<EventSystem>().AddListener<EGameState, EGameState>(EEvent.GameStateChange, OnGameStateChange);
        myCanvasGrounp = GetComponent<MyCanvasGrounp>();
    }

    private void OnGameStateChange(EGameState from, EGameState to)
    {
        switch (to)
        {
            case EGameState.OpenBag:
            case EGameState.OpenStorage:
                myCanvasGrounp.Visible = true;
                break;
            default:
                myCanvasGrounp.Visible = false;
                break;
        }
    }
}
